-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new annotation for Chisel Circuit serialization #1580
Conversation
@@ -86,6 +90,7 @@ class ChiselMainSpec extends AnyFeatureSpec with GivenWhenThen with Matchers wit | |||
} | |||
} | |||
|
|||
println(stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println(stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
One comment. I'm good with a merge after you strip the println
you tagged.
def transform(annotations: AnnotationSeq): AnnotationSeq = { | ||
val chiselOptions = view[ChiselOptions](annotations) | ||
val circuit = chiselOptions.chiselCircuit.getOrElse { | ||
throw new ChiselException(s"Unable to locate the elaborated circuit, did ${classOf[Elaborate].getName} run correctly") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new ChiselException(s"Unable to locate the elaborated circuit, did ${classOf[Elaborate].getName} run correctly") | |
throw new ChiselException(s"Unable to locate the elaborated circuit, did ${classOf[Elaborate].getName} run correctly?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm of two minds on whether or not this should throw an error. Some phases, like Elaborate
, are extremely simple and only do work if a sensitive annotation exists. Any user input checking is then pushed to a "checks" phase which runs before all work starts. (Note: that chisel3.stage.phases.Checks
does not current assert that a ChiselGeneratorAnnotation
exists... it probably should.)
By this logic, the error message here is a bit odd as it isn't that Elaborate
ran, but that there may have been user error where a circuit was never specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify: this is fine as it stands. I would just like some eventual unification in how we handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I see your point. I wasn't sure what to do here so I just decided to throw an error, but I'm happy to change this behavior
/* Caching the hashCode for a large circuit is necessary due to repeated queries. | ||
* Not caching the hashCode will cause severe performance degredations for large [[Circuit]]s. | ||
*/ | ||
override lazy val hashCode: Int = circuit.hashCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch.
@@ -63,7 +66,8 @@ class ChiselMainSpec extends AnyFeatureSpec with GivenWhenThen with Matchers wit | |||
files: Seq[String] = Seq.empty, | |||
stdout: Option[String] = None, | |||
stderr: Option[String] = None, | |||
result: Int = 0) { | |||
result: Int = 0, | |||
fileChecks: Map[String, File => Unit] = Map.empty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition.
ChiselCircuitAnnotation no longer extends CustomFileEmission, rather it is Unserializable. Also the --chisel-output-file is added to the ChiselCli. New phase AddSerializationAnnotations constructs a CircuitSerializationAnnotation from ChiselCircuitAnnotation and ChiselOutputFileAnnotation. Both .fir and .pb file formats are supported. Default format is .fir unless a --chisel-output-file is specified with a .pb extension.
9cefa64
to
3cc2132
Compare
* Bugfix - have AppendInfo use MultiInfo, rather than appending with : * Address reviewer feedback Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ChiselCircuitAnnotation no longer extends CustomFileEmission, rather it
is Unserializable. Also the --chisel-output-file is added to the
ChiselCli.
New phase AddSerializationAnnotations constructs a
CircuitSerializationAnnotation from ChiselCircuitAnnotation and
ChiselOutputFileAnnotation. Both .fir and .pb file formats are
supported. Default format is .fir unless a --chisel-output-file is
specified with a .pb extension.
This relies on a bugfix in chipsalliance/firrtl#1887 to work.
Contributor Checklist
docs/src
?Type of Improvement
API Impact
This is a binary incompatible modification from RC1, instead of
ChiselCircuitAnnotation
extendingCustomFileEmission
and only serializing to.fir
, I added a new annotationCircuitSerializationAnnotation
that can serialize to both.fir
and.pb
.Backend Code Generation Impact
No impact to Verilog, but Chisel can now natively emit
.pb
Desired Merge Strategy
Release Notes
Add support for direct protobuf serialization from Chisel via
CircuitSerializationAnnotation
Reviewer Checklist (only modified by reviewer)
Please Merge
?